package com.test.gpa.repostitory;

import com.test.gpa.domain.Menu;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface MenuSqlRepository extends JpaRepository<Menu, Long> {

    @Query(value = "SELECT DISTINCT m.`perms` FROM sys_user_role ur LEFT JOIN `sys_role` r ON ur.`role_id` = r.`id`LEFT JOIN `sys_role_menu` rm ON ur.`role_id` = rm.`role_id` LEFT JOIN `sys_menu` m ON m.`id` = rm.`menu_id` WHERE user_id =?", nativeQuery = true)
    List<String> selectPermsByUserId(Long id);
}
